<template>
  <div class="todo">
    <!--<div class="cover"></div>-->
    <Header :loginName="loginName"></Header>
    <Todo></Todo>
    <Footer></Footer>
  </div>
</template>

<script>
  import Header from '../components/header.vue'
  import Footer from '../components/footer.vue'
  import Todo from '../components/todo.vue'


  export default {
    name: 'Home',
    data() {
      return {
        msg: 'todo',
        loginName: ''
      }
    },
    methods: {
      login() {
        this.$router.push({path: 'login', params: {userId: 1111}},
          function complete() {

          })
      }
    },
    created() {
      var userName = this.$route.params.userName
      if (userName) {
        this.loginName = userName
      } else {
        var userInfo = JSON.parse(localStorage.getItem("userInfo"))
        if (userInfo) {
          this.loginName = userInfo.username
        } else {
          alert("用户信息丢失")
        }
      }
    },
    components: {
      Header,
      Footer,
      Todo
    }
  }
</script>

<style scoped lang="stylus">

</style>
